package com.qf.controller;

import com.qf.pojo.DtsTopic;
import com.qf.service.DtsTopicService;
import com.qf.util.ResponseUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
@RequestMapping("/admin/topic")
public class DtsAdminTopicController {

    @Autowired
    DtsTopicService dtsTopicService;
    @PostMapping("/delete")
    public Object delete(@RequestBody DtsTopic topic){
        DtsTopic object = dtsTopicService.delete(topic);
        return ResponseUtil.ok(object);
    }

    @PostMapping("/create")
    public Object create(@RequestBody DtsTopic topic) {
        DtsTopic object = dtsTopicService.create(topic);
        return ResponseUtil.ok(object);
    }

    @PostMapping("/update")
    public Object update(@RequestBody DtsTopic topic) {
        DtsTopic object = dtsTopicService.update(topic);
        return ResponseUtil.ok(object);
    }

    @GetMapping("/list")
    public Object list(
            @RequestParam(value = "page",required = false, defaultValue = "1") Integer page,
            @RequestParam(value = "limit",required = false, defaultValue = "20")Integer limit,
            String title,String subtitle,String sort,String order
    ){
        Map<String, Object> data = dtsTopicService.queryPage(page,limit,title,subtitle,sort,order);
        return ResponseUtil.ok(data);
    }
}